package POS.GUI;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

/**
 * A POS System for a
 * small restaurant.
 * 
 * Maeghan Colvin and Jennifer Haveman
 * CSC 289 0B01
 * February 22, 2014
 */

public class SidesPanel extends JPanel
{
    // Variables.
    private final JButton friesButton, hushpupButton, coleslawButton, 
            beansButton, macButton, potatoesButton;
    private String foodPrice;
    private String foodItem;
    
    /**
     * Constructor
     * Creates the side dish panel.
     */
    public SidesPanel()
    {
        // Set layout and border.
        super();
        setLayout(new GridLayout(7,1));
        setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
        setFont(new Font("Arial",Font.BOLD,20));
        
        // Instantiate  and name buttons.
        friesButton = new JButton("Fries");
        hushpupButton = new JButton("Hush Puppies");
        coleslawButton = new JButton("Coleslaw");
        beansButton = new JButton("Beans");
        macButton = new JButton("Mac-n-Cheese");
        potatoesButton = new JButton("Baked Potato");
        
        // adds action listener
        friesButton.addActionListener(new AddOrder());
        hushpupButton.addActionListener(new AddOrder());
        coleslawButton.addActionListener(new AddOrder());
        beansButton.addActionListener(new AddOrder());
        macButton.addActionListener(new AddOrder());
        potatoesButton.addActionListener(new AddOrder());
        
        // Add buttons to panel
        add(friesButton);
        add(hushpupButton);
        add(coleslawButton);
        add(beansButton);
        add(macButton);
        add(potatoesButton);
    }
    
    /**
     * Action listener that gets the name of the button and the price
     * and adds it to the order and price DefaultListModel.
     */
    class AddOrder implements ActionListener
    {
        @Override
        public void actionPerformed(ActionEvent e) 
        {
            MenuPane.sendOrderButton.setEnabled(true);
            // gets the source of the actionListener call
            JButton button = (JButton) e.getSource();
            // gets the text of the button
            foodItem = button.getText();
            // sets price
            foodPrice = "1.99";
            // sends name and price to lists for display
            MenuPane.getOrders(foodItem);
            MenuPane.getPrice(foodPrice);
        }
        
    }
} 